package br.com.moove.bananasfit.view;


import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.RetryPolicy;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.Volley;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import br.com.moove.bananasfit.R;
import br.com.moove.bananasfit.model.OnListItemClickPessoaJuridica;
import br.com.moove.bananasfit.model.PessoaFisica;
import br.com.moove.bananasfit.model.PessoaJuridica;

public class ListaPessoaJuridicaActivity extends ActionBarActivity implements
		OnListItemClickPessoaJuridica {

	ListPessoaJuridicaFragment fragmentLista;

	PessoaFisica usuario;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
		setContentView(R.layout.activity_lista_p_juridica);
		usuario = (PessoaFisica) getIntent().getSerializableExtra("Usuario");
		
		fragmentLista = ListPessoaJuridicaFragment.getInstance(getIntent()
				.getIntExtra("IdServico", 0), getIntent().getStringExtra("NomePJ"));

		getFragmentManager().beginTransaction()
				.replace(R.id.listalayout, fragmentLista).commit();

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.pjuridica_item_lista, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	@Override
	public void onListPJClick(PessoaJuridica pessoaJuridica) {
		// TODO Auto-generated method stub		
		
		
		Intent intent = new Intent(this, DetalhesPJuridicaActivity.class);
		intent.putExtra("pessoaJuridica", pessoaJuridica);
		intent.putExtra("Usuario", usuario);
		startActivity(intent);
	}
}
